<?php

class WeddingController extends Controller
{
	public $layout='wedding';

	public function accessRules()
	{
		return array(
			
		);
	}
public function actionHome()
	{
        
		$this->render('home');
	}
	
	public function actionPoll()
	{
		if($_POST)
		{
			$quesid=$_POST['hide'];
			$opt=$_POST['Option'];
			$Option=PollOption::model()->find('question_id=? AND id=?',array($quesid,$opt));
			$Question=PollQuestion::model()->find('id=?',array($quesid));
			// Counter Increment
			$optioncount=$Option->count;
			$questcount=$Question->count;
			$optioncount+=1;
			$questcount+=1;
			$Option->count=$optioncount;
			$Question->count=$questcount;
			$Option->save();
			$Question->save();

			// Percent Calculation
			$Option1=PollOption::model()->findALL('question_id=?',array($quesid));
				foreach ($Option1 as $Option2) {
				$percent=($Option2->count/$Question->count)*100;
				$Option2->percent=$percent;
				$Option2->save();
				$this->render('ajax',array('id'=>$quesid));
			}
		}
			
			$this->render('poll');
	}


public function actionShow()
{
	$this->layout='';
	//var_dump($_GET['q']);
	//var_dump($_GET['p']);exit;
		$quesid=$_GET['q'];
			$opt=$_GET['p'];
			$Option=PollOption::model()->find('question_id=? AND id=?',array($quesid,$opt));
			$Question=PollQuestion::model()->find('id=?',array($quesid));
			// Counter Increment
			$optioncount=$Option->count;
			$questcount=$Question->count;
			$optioncount+=1;
			$questcount+=1;
			$Option->count=$optioncount;
			$Question->count=$questcount;
			$Option->save();
			$Question->save();

			// Percent Calculation
			$Option1=PollOption::model()->findALL('question_id=?',array($quesid));
				foreach ($Option1 as $Option2) {
				$percent=($Option2->count/$Question->count)*100;
				$Option2->percent=$percent;
				$Option2->save();
					}
	$this->render('ajax',array('q'=>$_GET['q']));
}
	public function actionWelcome()
	{
         $this->layout = 'new';
		$this->render('welcome_full');
	}
	public function actionOursite()
	{
        $this->layout = 'new';
		$this->render('our_site_full');
	}
	public function actionOurparents()
	{
         $this->layout = 'new';
		$this->render('our_parents_full');
	}
public function actionOurstory()
	{
        
		$this->render('ourstory');
	}
	
public function actionEvents()
	{
        
		$this->render('invitation');
	}
public function actionPhotoalbum()
	{
        
		$this->render('photoalbum');
	}

	public function actionIntroduction()
	{
		$this->layout="introduction";
		$this->render('introduction');
	}

	public function actionPhoto(){
		$id=$_GET['id'];
		$this->render('photo',array('album_id'=>$id));
	}

public function actionMapofevents()
	{
        
		$this->render('mapofevents');
	}
	public function actionGuestbook()
	{
		$model=new Message();
		if($_POST)
		{
		
		$model->name=$_POST['item1'];
 		$model->email=$_POST['item2'];
		$model->message=$_POST['item3'];
		if($model->save())
			Yii::app()->user->setFlash('success', "your message send successfully!");
		}


		$this->render('guestbook',array('model'=>$model));
	}
	public function actionRsvp()
	{
		$this->render('rsvp');
	}
	public function actionContactus()
	{
		$this->render('contactus');
	}


	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}